<?php
/* @var $this BackendController */
/* @var $model User */

$this->breadcrumbs=array(
	Yii::t('UserModule.base','Users')=>array('index'),
	Yii::t('UserModule.base','Manage'),
);

$this->menu=array(
    array('label'=>'<span class="glyphicon glyphicon-user"></span>&nbsp'.Yii::t('UserModule.base','Manage Users'), 'url'=>array('/user/backend/admin')),
    array('label'=>'<span class="glyphicon glyphicon-plus"></span>&nbsp'.Yii::t('UserModule.base','Create User'), 'url'=>array('/user/backend/create')),
    array('label'=>'<span class="glyphicon glyphicon-list"></span>&nbsp'.Yii::t('UserModule.base','List Users'), 'url'=>array('/user/backend/index')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#user-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>


        <span class="h3"><?php echo Yii::t('UserModule.base','Manage Users')?></span>
<div class="panel panel-default">

    <div class="panel-body">

        <?php if(Yii::app()->user->hasFlash('message')):?>
            <div class="alert alert-danger">
                <?php echo Yii::app()->user->getFlash('message');?>
            </div>
        <?php endif;?>
<p>
<?php echo Yii::t('UserModule.base','You may optionally enter a comparison operator')?> (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
<?php echo Yii::t('UserModule.base','or')?> <b>=</b>) <?php echo Yii::t('UserModule.base','at the beginning of each of your search values to specify how the comparison should be done.')?>
</p>


<?php echo CHtml::link(Yii::t('UserModule.base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'user-grid',
    'template'=>'{items}{pager}',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
    'pager' => array('cssFile' => Yii::app()->theme->baseUrl . '/assets/gridview/pager.css'),
    'baseScriptUrl'=>Yii::app()->theme->baseUrl.'/assets/gridview',
	'columns'=>array(

        array(
            'name' => 'id',
            'type' => 'raw',
            'htmlOptions' => array('style'=>'width:50px'),
        ),

        array(
            'name' => 'avatar',
            'type' => 'html',
            'value' => '$data->getImageForGrid()',
            'htmlOptions' => array('style'=>'width:40px'),
        ),
		'name',
		'login',
		'email',
        array(
            'name'=>'create_time',
            'type'=>'raw',
            'value'=>'CLocale::getInstance(Yii::app()->getLocale()->id)->dateFormatter->formatDateTime(strtotime($data->create_time),"long","short")',
        ),
        array(
            'name'=>'role',
            'type' => 'raw',
            'htmlOptions' => array('style'=>'width:50px'),
        ),
		/*
		'avatar',

		'update_time',
		'create_user_id',
		'update_user_id',

		'active',
		'login_time',
		'last_login_time',
		*/
		array(
            'class'=>'CButtonColumn',
            'htmlOptions' => array('style'=>'width:90px'),
            'template'=>'{email}&nbsp{view}&nbsp{update}&nbsp{delete}',
            'buttons'=>array
            (
                'email' => array
                (
                    'label'=>'Отправить уведомление на email',
                    'imageUrl'=>Yii::app()->theme->baseUrl.'/img/email.png',
                    'url'=>'Yii::app()->createUrl("/user/backend/sendEmail", array("id"=>$data->id,"name"=>$data->name,"email"=>$data->email))',
                ),
            ),

        ),
	),
)); ?>
    </div>
</div>